package com.qiqv.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @author hjr
 * @version 1.0
 * @date 2023/2/13 20:27
 */
@Data
public class QiQvResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 状态响应码
     */
    public String responseCode;

    /**
     * 响应信息
     */
    public String responseMsg;

    /**
     * 错误代码
     */
    public String errorCode;

    /**
     * 请求失败时的错误原因
     */
    public String errorMsg;

    /**
     * 响应数据
     */
    public T data;


    public static QiQvResult OK(){
        return QiQvResult.OK(null);
    }

    public static QiQvResult OK(Object data){
        QiQvResult result = new QiQvResult();
        result.setData(data);
        result.setResponseCode("00");
        result.setResponseMsg("success");
        return result;
    }

    public static QiQvResult FAIL(String responseCode,String errorCode,String errorMsg){
        QiQvResult result = new QiQvResult();
        result.setResponseCode(responseCode);
        result.setErrorCode(errorCode);
        result.setErrorMsg(errorMsg);
        return result;
    }

    public static QiQvResult FAIL(String errorCode,String errorMsg){
        QiQvResult result = new QiQvResult();
        result.setResponseCode("01");
        result.setErrorCode(errorCode);
        result.setErrorMsg(errorMsg);
        return result;
    }


}
